package org.sixtynine.stock.entity;

/**
 * @author Thilan
 *
 */

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.DecimalMin;

import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;

@Entity
@Table(name = "ANNUAL_SHARE_DATA")
public class AnnualShareData extends BaseEntity {

	private int id;
	private int year;

	private double netProfit;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double numberOfShares;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double revenues;

	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double ebitda;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double dividents;

	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double closingPrice;

	private Company company;

	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double recurringProfit;

	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double aveShareOfShare;

	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double dividenOfShare;

	@Id
	@Column(name = "ID", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "YEAR_CODE", nullable = true)
	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	@Column(name = "NET_PROFIT")
	public double getNetProfit() {
		return netProfit;
	}

	public void setNetProfit(double netProfit) {
		this.netProfit = netProfit;
	}

	@Column(name = "NUMBER_OF_SHARES")
	public double getNumberOfShares() {
		return numberOfShares;
	}

	public void setNumberOfShares(double numberOfShares) {
		this.numberOfShares = numberOfShares;
	}

	@Column(name = "REVENUES")
	public double getRevenues() {
		return revenues;
	}

	public void setRevenues(double revenues) {
		this.revenues = revenues;
	}

	@Column(name = "EBITDA")
	public double getEbitda() {
		return ebitda;
	}

	public void setEbitda(double ebitda) {
		this.ebitda = ebitda;
	}

	@Column(name = "DIVIDENTS")
	public double getDividents() {
		return dividents;
	}

	public void setDividents(double dividents) {
		this.dividents = dividents;
	}

	@Override
	public boolean equals(Object obj) {
		return (id == ((AnnualShareData) obj).getId());
	}

	@ManyToOne
	@JoinColumn(name = "COMPANY_ID")
	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	@Column(name = "RECURRING_PROFIT")
	public double getRecurringProfit() {
		return recurringProfit;
	}

	public void setRecurringProfit(double recurringProfit) {
		this.recurringProfit = recurringProfit;
	}

	@Column(name = "CLOSING_PRICE")
	public double getClosingPrice() {
		return closingPrice;
	}

	public void setClosingPrice(double closingPrice) {
		this.closingPrice = closingPrice;
	}

	@Column(name = "AVE_SHARE_OF_SHARE")
	public double getAveShareOfShare() {
		return aveShareOfShare;
	}

	public void setAveShareOfShare(double aveShareOfShare) {
		this.aveShareOfShare = aveShareOfShare;
	}

	@Column(name = "DIVIDENT_OF_SHARE")
	public double getDividenOfShare() {
		return dividenOfShare;
	}

	public void setDividenOfShare(double dividenOfShare) {
		this.dividenOfShare = dividenOfShare;
	}

}
